package org.openmore.consumer.service.feign;

import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import org.openmore.common.enums.Platform;
import org.openmore.consumer.dto.common.UserDto;
import org.openmore.consumer.entity.User;
import org.openmore.consumer.service.feignImpl.UserServiceImpl;
import org.openmore.consumer.dto.common.BaseResponse;
import org.openmore.consumer.entity.enums.UserType;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;

@Service
@FeignClient(value = "openmore-opc", fallbackFactory = UserServiceImpl.class)
public interface UserService {

    /**查询用户*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/user/query")
    public BaseResponse selectAllByPage(@RequestParam(required = false) @ApiParam(value = "应用ID") String tenantId,
                                        @RequestParam(required = false) @ApiParam(value = "用户名称")String username,
                                        @RequestParam(defaultValue = "USER") @ApiParam(value = "用户类型", required = true) UserType type,
                                        @RequestParam(required = false) @ApiParam(value = "是否是VIP")Boolean isVip,
                                        @RequestParam(required = false) @ApiParam(value = "手机号")String phone,
                                        @RequestParam(required = false) @ApiParam(value = "用户来源平台") Platform platform,
                                        @RequestParam(required = false) @ApiParam(value = "用户注册开始时间") Date startTime,
                                        @RequestParam(required = false) @ApiParam(value = "用户注册结束时间")Date endTime,
                                        @RequestParam(required = false, defaultValue = "1") @ApiParam(value = "分页第几页") Integer pageNum,
                                        @RequestParam(required = false, defaultValue = "10") @ApiParam(value = "每页多少记录") Integer pageSize);


    /**根据ID查询用户*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/user/{id}")
    public BaseResponse getUserById(@PathVariable @ApiParam(required = true, value = "id") String id);


    /**更新用户信息和缓存*/
    @RequestMapping(method = RequestMethod.PUT, value = "/api/user")
    public BaseResponse updateUser(@RequestBody @ApiParam(value = "新信息", required = true) UserDto user);

    /**更新用户信息*/
    @RequestMapping(method = RequestMethod.PUT, value = "/api/user/noCacheUpdate")
    public BaseResponse updateUserNoCache(@RequestBody @ApiParam(value = "新信息", required = true) UserDto user);

    /**创建用户*/
    @RequestMapping(method = RequestMethod.POST, value = "/api/user", consumes = {APPLICATION_JSON_UTF8_VALUE})
    public BaseResponse insertUser(@RequestBody @ApiParam(value = "创建", required = true) UserDto user);

    /**删除用户信息*/
    @RequestMapping(method = RequestMethod.DELETE, value = "/api/user/{id}")
    public BaseResponse deleteUser(@PathVariable @ApiParam(value = "id", required = true) String id);

    /**设置用户禁言*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/user/forbiddenWords/{id}/{status}")
    public BaseResponse forbiddenWords(@PathVariable @ApiParam(value = "id", required = true) String id,
                                       @PathVariable @ApiParam(value = "status:true:禁言、false：解禁", required = true) Boolean status);
}
